<?php
/* @var $this SiteController */

$this->pageTitle=Yii::app()->name;
?>
<div class="left-col">    
        <?php
                $monhocModels=  MonHoc::model()->findAll();
                foreach ($monhocModels as $monhoc){
                        $baigiangModels=$monhoc->getBaiGiangArray(3);
                        if(!empty($baigiangModels)){
                                $dataProvider=new CArrayDataProvider($baigiangModels);
                                $this->beginWidget('zii.widgets.CPortlet', array(
                                        'title'=>$monhoc->name,
                                ));
                                        $this->widget('zii.widgets.CListView', array(
                                                'dataProvider'=>$dataProvider,
                                                'itemView'=>'_baigiang_view',
                                                'itemsTagName'=>'div',
                                                'itemsCssClass'=>'baigiang-items'
                                        ));
                                $this->endWidget();
                        }
                }
        ?>
</div>

<div class="right-col">
    <?php
        if (!isset(Yii::app()->user->userId) ) {
                $this->beginWidget('zii.widgets.CPortlet', array(
                        'title'=>'Đăng nhập',
                ));
                        $this->renderPartial('_login');
                $this->endWidget();
        }
        
        $this->beginWidget('zii.widgets.CPortlet', array(
                    'title'=>'Tìm kiếm',
            ));
                $this->renderPartial('_search');
        $this->endWidget();
    
        $this->beginWidget('zii.widgets.CPortlet', array(
                'title'=>'Thư mục bài giảng',
        ));
                $this->widget('CTreeView',array(
                            'data'=>$this->getFolderTreeData(),
                            'animated'=>'fast', //quick animation
                            'collapsed'=>'false',//remember must giving quote for boolean value in here
                            'htmlOptions'=>array(
                                    'class'=>'treeview-red',//there are some classes that ready to use
                            ),
                ));
        $this->endWidget();
    ?>
</div>

<div style="clear: both"></div>

<script type="text/javascript">
        $(function(){
                $('.tree-searchable-item').click(function(){
                        var url=$(this).attr('href');
                        $.ajax({
                                url:url,
                                success:function(data){
                                        $('.left-col').html(data);
                                }
                        });
                });
        })
</script>